//
//  SNAssociatorCell.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/16.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNAssociatorCell.h"

@interface SNAssociatorCell()
@property (weak, nonatomic) IBOutlet UILabel *keyLabel;
@property (weak, nonatomic) IBOutlet UILabel *valueLabel;

@end
@implementation SNAssociatorCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)configWithUserDetailInfo:(ZXUserDetailInfo *)userDetailInfo indexPath:(NSIndexPath *)indexPath{
    _userDetailInfo = userDetailInfo;
    
    switch (indexPath.row) {
        case 0:
            self.keyLabel.text = @"姓名";
            self.valueLabel.text = userDetailInfo.custName;
            break;
//        case 1:
//            self.keyLabel.text = @"社员编号";
//            self.valueLabel.text = userDetailInfo.ORGANID;
//            break;
        case 1:
            self.keyLabel.text = @"身份证号码";
            self.valueLabel.text = userDetailInfo.idCard;
            break;
        case 2:
            self.keyLabel.text = @"手机号码";
            self.valueLabel.text = userDetailInfo.tel;
            break;
        case 3:
        {
            self.keyLabel.text = @"所在地区";
            if (userDetailInfo.address == nil || [userDetailInfo.address isEqualToString:@""]) {
                self.valueLabel.text = @"";
                return;
            }
            NSMutableString * strM = [NSMutableString string];
            NSString *searchText = userDetailInfo.address;
            NSRange range = [searchText rangeOfString:@"[\u4E00-\u9FFF]+" options:NSRegularExpressionSearch];
            while (range.location != NSNotFound) {
                NSLog(@"range ：%@", [searchText substringWithRange:range]);
                
                [strM appendString:[NSString stringWithFormat:@"%@ ",[searchText substringWithRange:range]]];
                searchText =  [searchText substringFromIndex:range.location+range.length];
                range = [searchText rangeOfString:@"[\u4E00-\u9FFF]+" options:NSRegularExpressionSearch];
            }
            
            self.valueLabel.text = strM;//userDetailInfo.ADDRESS;
        }
       
            break;
        case 4:
            self.keyLabel.text = @"身份";
            self.valueLabel.text = userDetailInfo.usertypename;
            break;
        case 5:
            self.keyLabel.text = @"隶属组织";
            self.valueLabel.text = userDetailInfo.fullName;
            break;
        case 6:
            self.keyLabel.text = @"承包土地面积";
            self.valueLabel.text = [NSString stringWithFormat:@"%@(公顷)",userDetailInfo.landArea];
            break;
        case 7:
            self.keyLabel.text = @"实际土地面积";
            self.valueLabel.text = [NSString stringWithFormat:@"%@(公顷)",userDetailInfo.actualArea];
            break;
        default:
            break;
    }
    
    
}

@end
